package rc.memory;

import java.util.List;

import rc.Bank;

public class BankMemoryRCAware implements Bank
{
	public Account[] accounts;

	public BankMemoryRCAware(List<Integer> balances)
	{
		accounts = new Account[balances.size()];

		for (int i = 0; i < accounts.length; i++)
			accounts[i] = new Account(balances.get(i));
	}

	public void transfer(int from, int to, int amount)
	{
		accounts[from].remove(amount);
		accounts[to].add(amount);
	}

	public void showBalances()
	{
		int total = 0;

		for (int i = 0; i < accounts.length; i++) {
			total += accounts[i].getBalance();
			System.out
					.println("Account " + i + ": " + accounts[i].getBalance());
		}

		System.out.println("Total: " + total);
	}
}